var main = null;
var showMenu = false;
var menu = null;
var add = null;
var detail = null;

// 所有方法都放到这里  
mui.plusReady(function() {
	// 初始化数据库  
	initDb();

	// 侧滑菜单  
	main = qiao.h.indexPage();
	var menuoptions = qiao.h.page('menu', {
		styles: {
			left: 0,
			width: '70%',
			zindex: -1
		}
	});
	menu = mui.preload(menuoptions);
	qiao.on('.mui-icon-bars', 'tap', opMenu);
	main.addEventListener('maskClick', opMenu);
	mui.menu = opMenu;

	// 退出  
	mui.back = function() {
		if($('.adda').is(':hidden')) {
			hideAdd();
		} else if(showMenu) {
			closeMenu();
		} else {
			qiao.h.exit();
		}
	};
	qiao.h.indexPage = function() {
		return plus.webview.getWebviewById(plus.runtime.appid);
	};
	qiao.on('.mui-icon-bars', 'tap', opMenu);
	mui.menu = opMenu;
	main.addEventListener('maskClick', opMenu);

	// 退出  
	mui.back = function() {
		if($('.adda').is(':hidden')) {
			hideAdd();
		} else if(showMenu) {
			closeMenu();
		} else {
			qiao.h.exit();
		}
	};

	function opMenu() {
		if(showMenu) {
			closeMenu();
		} else {
			openMenu();
		}
	}

	function openMenu() {
		if($('.adda').is(':visible')) {
			menu.show('none', 0, function() {
				main.setStyle({
					mask: 'rgba(0,0,0,0.4)',
					left: '70%',
					transition: {
						duration: 150
					}
				});

				showMenu = true;
			});
		}
	}

	function closeMenu() {
		main.setStyle({
			mask: 'none',
			left: '0',
			transition: {
				duration: 100
			}
		});

		showMenu = false;
		setTimeout(function() {
			menu.hide();
		}, 300);
	}
});list